import axios from "axios";
import './axiosConfig';

// 首页歌单
export const getTuijiangedan = () => axios.get(`/gedan/get`);
// 推荐mv(首页) 推荐mv页
export const getTuijianmv = () => axios.get('/mv/getMv');
// 推荐歌曲(首页) 推荐歌曲页
export const getTuijiansong = () => axios.get('/music/getMusic');
// 获取歌单详情
export const getGedanxiangqing = (id) => axios.get(`/gedan/getGedanById?id=${id}`);
// 获取歌单音乐
export const getGedanSong = (ids) => axios.get(`/music/getMusicById?id=${ids}`);
// 获取mv详情
export const getMvxiangqing = (id) => axios.get(`/mv/getMvById?id=${id}`);
// 获取音乐url和歌曲详细信息
export const getGequurl = (id) => axios.get(`/music/getMusicById?id=${id}`);
// 歌单分类
export const getGedanfenlei = () => axios.get('/gedan/getTag');
// 获取歌单类型内容
export const getGedanneirong = (id) => axios.get(`/gedan/getGedanByGedanTagId?gedantagid=${id}`);
// 获取歌曲类型
export const getSongsType = () => axios.get('/music/getMusicType');
// 最新歌曲(最新歌曲页)
export const getZuixinsongByType = (id) => axios.get(`/music/getMusicByMusicTypeId?musictypeid=${id}`);
// 获取歌手类型
export const getGeshoufenlei = () => axios.get('/singer/getSingerType');
// 获取热门歌手
export const getRemengeshou = (id) => axios.get(`/singer/getSingerBySingerTypeId?singertypeid=${id}`);
// 注册
export const registerUser = (form) => axios.post('/register/user', form);
// 登录
export const loginUser = (username, password) => axios.post('/login/user', {
	username,
	password
});
// 判断是否收藏
// userid type(1gedan 2mv) mvid gedanid
export const pdCollect = (userid, type, id) => {
	if (type === 1) {
		return axios.get(`/collect/pdCollect?userid=${userid}&gedanid=${id}&type=${type}`);
	} else {
		return axios.get(`/collect/pdCollect?userid=${userid}&mvid=${id}&type=${type}`);
	}
};
// 取消收藏
// userid type(0music 1gedan 2mv) mvid gedanid musicid
export const deleteCollect = (userid, type, id) => {
	if (type === 0) {
		return axios.post('/collect/delete', {
			userid,
			type,
			musicid: id
		});
	} else if (type === 1) {
		return axios.post('/collect/delete', {
			userid,
			type,
			gedanid: id
		});
	} else {
		return axios.post('/collect/delete', {
			userid,
			type,
			mvid: id
		});
	}
};
// 添加收藏
// userid type(0music 1gedan 2mv) mvid gedanid musicid
export const addCollect = (userid, type, id) => {
	if (type === 0) {
		return axios.post('/collect/add', {
			userid,
			type,
			musicid: id
		});
	} else if (type === 1) {
		return axios.post('/collect/add', {
			userid,
			type,
			gedanid: id
		});
	} else {
		return axios.post('/collect/add', {
			userid,
			type,
			mvid: id
		});
	}
};
// 添加评论
// userid type(0歌曲 1歌单 2mv) musicid gedanid mvid content create_time
export const addComment = (userid, type, id, content, create_time) => {
	if (type === 0) {
		return axios.post('/comment/add', {
			userid,
			type,
			musicid: id,
			content,
			create_time
		});
	} else if (type === 1) {
		return axios.post('/comment/add', {
			userid,
			type,
			gedanid: id,
			content,
			create_time
		});
	} else {
		return axios.post('/comment/add', {
			userid,
			type,
			mvid: id,
			content,
			create_time
		});
	}
};
// 获取评论
// type musicid gedanid mvid
export const getComment = (type, id) => {
	if (type === 0) {
		return axios.get(`/comment/get?type=${type}&musicid=${id}`);
	} else if (type === 1) {
		return axios.get(`/comment/get?type=${type}&gedanid=${id}`);
	} else {
		return axios.get(`/comment/get?type=${type}&mvid=${id}`);
	}
};
// 查看用户详细信息
// id
export const getUserInfo = (id) => axios.get(`/info/getUserInfo?id=${id}`);
// 获取收藏
// userid type(0music 1gedan 2mv)
export const getCollect = (userid, type) => axios.get(`/collect/get?userid=${userid}&type=${type}`);
// 修改用户
export const editUser = (form) => axios.post('/info/editUserInfo', form);
// 获取新闻类型
export const getNewsType = () => axios.get('/news/getNewsType');
// 获取新闻内容
export const getNews = (id) => axios.get(`/news/getNewsByNewsTypeId?newstypeid=${id}`);
// 搜索
export const search = (keyword, type) => axios.get(`/search?keyword=${keyword}&type=${type}`);
// 添加歌单
export const addGedan = (form) => axios.post('/gedan/add', form);
// 通过userid获取歌单
export const getGedanByUserId = (id) => axios.get(`/gedan/getGedanByUserId?userid=${id}`);
// 修改歌单
export const editGedan = (form) => axios.post('/gedan/edit', form);
// 删除歌单
export const deleteGedan = (id)=> axios.get(`/gedan/delete?id=${id}`);